﻿#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License, as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;

namespace ExtremeML.Packaging
{
	// This is a partial class that adds custom functionality to its auto-generated partner.
	public sealed partial class WorkbookStylesPartWrapper
	{
		#region Custom Properties

		/// <summary>
		/// Gets the containing package as a <see cref="SpreadsheetDocumentWrapper"/>.
		/// </summary>
		public SpreadsheetDocumentWrapper Spreadsheet
		{
			get { return (SpreadsheetDocumentWrapper)Package; }
		}

		#endregion
		#region Custom Methods


		#endregion
		#region Overrides


		#endregion
		#region Implementation Methods


		#endregion
		#region Static Methods

		/// <summary>
		/// Returns a <see cref="WorkbookStylesPart"/> populated with custom default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
        /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
        /// <returns>A new instance of <see cref="WorkbookStylesPart"/>.</returns>
		internal static new WorkbookStylesPart CreateCustomDefaultPart(
			OpenXmlPartContainer container,
            params object[] args)
		{
			var part = container.AddNewPart<WorkbookStylesPart>();

			new Stylesheet(
				new Fonts(
					new Font(
						new FontSize { Val = 11D },
						new Color { Theme = (UInt32Value)1U },
						new FontName { Val = "Calibri" },
						new FontFamilyNumbering { Val = 2 },
						new FontScheme { Val = FontSchemeValues.Minor })
				) { Count = (UInt32Value)1U },
				new Fills(
					new Fill(
						new PatternFill { PatternType = PatternValues.None }),
					new Fill(
						new PatternFill { PatternType = PatternValues.Gray125 })
				) { Count = (UInt32Value)2U },
				new Borders(
					new Border(
						new LeftBorder(),
						new RightBorder(),
						new TopBorder(),
						new BottomBorder(),
						new DiagonalBorder())
				) { Count = (UInt32Value)1U },
				new CellStyleFormats(
					new CellFormat { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }
				) { Count = (UInt32Value)1U },
				new CellFormats(
					new CellFormat { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }
				) { Count = (UInt32Value)1U },
				new CellStyles(
					new CellStyle { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }
				) { Count = (UInt32Value)1U },
				new DifferentialFormats { Count = (UInt32Value)0U },
				new TableStyles { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium9", DefaultPivotStyle = "PivotStyleLight16" }
			).Save(part);

			return part;
		}

		#endregion
	}
}
